********************************************************************************
*                          Replication Code for Figures for Peters Walsh (2024)
*******************************************************************************

********************************** Preliminaries *******************************

clear
set more off

cd ..

global maindir `c(pwd)'

global code "Code"
global rawdata "RawData"
global ProcessedData "ProcessedData"
global output "Outputs"

cd Code

local graphfont "Palatino"
graph set eps fontface `graphfont'
graph set eps fontfaceserif `graphfont'
graph set eps  /*echo back preferences*/
 
graph set window fontface `graphfont'
graph set window fontfaceserif `graphfont'
graph set window /*echo back preferences*/




********************************** Figure 3a **********************************

*data is a direct export from the Longitudinal Business Database in 2022
import delimited "$maindir/RawData/ProductManu.csv",clear
rename v1 nprods

lab define newlabel 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10+", modify
lab val nprods newlabel


** CDF of manufacturing products 
twoway (line v2 nprods, lwidth(thick) color("0  80 178")) ///
(line v3 nprods, lwidth(thick) color("10 110 220") ) ///
(line v4 nprods, lwidth(thick) color("30 150 220")) ///
(line v5 nprods, lwidth(thick) color(emerald)) ///
(line v6 nprods, lwidth(thick) color("209 80 0") ) ///
(line v7 nprods, lwidth(thick) color("cranberry") ), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Number of Products},size(large))  ytitle({bf: C.D.F},size(large)) ///
 ylabel(,labsize(medlarge)) xlabel(,labsize(medlarge) valuelabel) ///
legend( symys(*.5) symxs(*.5) size(4) rows(3) ring(0)  position(5) region(lstyle(solid)) label(1 "1987") label(2 "1992") label(3 "1997") label(4 "2002") label(5 "2007") label(6 "2012")) 


graph export "$maindir/Outputs/Figure3a.pdf",replace

********************************** Figure 3b **********************************

*data is a direct export from the Longitudinal Business Database in 2022
import delimited "$maindir/RawData/ProductServ.csv",clear
rename v1 nprods

lab define newlabel 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10+", modify
lab val nprods newlabel


** CDF of establishments in services
twoway (line v2 nprods, lwidth(thick) color("0  80 178")) ///
(line v3 nprods, lwidth(thick) color("10 110 220") ) ///
(line v4 nprods, lwidth(thick) color(emerald)) ///
(line v5 nprods, lwidth(thick) color("209 80 0") ) ///
(line v6 nprods, lwidth(thick) color("cranberry") ), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Number of Establishments},size(large))  ytitle({bf: C.D.F},size(large)) ///
 ylabel(,labsize(medlarge)) xlabel(,labsize(medlarge) valuelabel) ///
legend( symys(*.5) symxs(*.5) size(4) rows(3) ring(0)  position(5) region(lstyle(solid)) label(1 "1980") label(2 "1990") label(3 "2000") label(4 "2010") label(5 "2015") ) 


graph export "$maindir/Outputs/Figure3b.pdf",replace


********************************** Figure 4a **********************************

*data is a direct export from the Longitudinal Business Database in 2022
import delimited "$maindir/RawData/Sales.csv",clear

rename emp emp_d
rename sale sales_d
drop spw

save "Sales.dta",replace

import delimited "$maindir/RawData/Lifetime_data.csv", clear

rename (v1 v2 v3 v4) (age sales emp markup)

merge 1:1 age using "Sales.dta"
drop if _merge==2
drop _merge

preserve
import delimited "$maindir/ProcessedData/Figure_4a.csv",clear

rename firmage_years_ age
rename logaveragesales_differencetoyear sales_model

tempfile full
saveold `full',replace

restore

merge 1:1 age using `full'
replace sales_model=0 if age==0
drop if _merge==2
drop _merge

drop if age>15

twoway (line  sales_model age, lwidth(thick) color("0 80 178")) ///
(connected  sales_d age, lwidth(med) color("209 80 0")), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Age}, size(large))  ///
  l2title({bf: Log Average Sales},size(large)) ///
    l1title(Difference from Age 0, size(medlarge)) ///
 xlabel(,labsize(medlarge)) /// 
ylabel(0 (0.1) 0.9, gmax gmin labsize(medlarge) ) ///
legend( symys(*.5) symxs(*.5) size(4 )  ring(0) rows(1) position(5) region(lstyle(solid)) label(1 "Calibrated Model") label(2 "Data") label(3 "Data")) 

graph export "$maindir/Outputs/Figure4a.pdf",replace

rm "Sales.dta"

********************************** Figure 4b **********************************

*data is a direct export from the Longitudinal Business Database in 2022
import delimited "$maindir/RawData/Markup_Data.csv",clear
replace markup=markup*100

preserve
import delimited "$maindir/ProcessedData/Figure_4b.csv",clear
rename firmage_years_ age
rename markupgrowth_differencetoyear0_ markup_model

tempfile full
saveold `full',replace

restore

merge 1:1 age using `full'
replace markup_model=0 if age==0
drop if _merge==2
drop _merge

drop if age>15

twoway (line  markup_model age, lwidth(thick) color("0 80 178")) ///
(connected  markup age, lwidth(med) color("209 80 0")), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Age}, size(large))  ///
  l2title({bf: Markup},size(large)) ///
    l1title(Pct. Points Above Age 0, size(medsmall)) ///
ylabel(0 (2) 15, gmax gmin labsize(medlarge) ) ///
 xlabel(,labsize(medlarge)) /// 
legend( symys(*.5) symxs(*.5) size(4 )  ring(0) rows(1) position(5) region(lstyle(solid)) label(1 "Calibrated Model") label(2 "Data"))

graph export "$maindir/Outputs/Figure4b.pdf",replace

********************************** Figure 5a **********************************


import delimited "$maindir/ProcessedData/Figure_5a.csv",clear
gen class= _n
rename employmentshare dist1

preserve 


import delimited "$maindir/RawData/bds_f_sz_release.csv",clear
keep if year==1980

keep fsize  emp
gen class=1
replace class= class[_n-1]+1 if _n>1

gen sumemp=sum(emp)
replace sumemp=sumemp[_N]
gen dist2=emp/sumemp

tempfile data
saveold `data',replace

restore

merge 1:1 class using `data'


labmask class, values(fsize)

graph bar (asis) dist1 dist2, over(class,   label( angle(45))) ///
 graphregion(color(white)) legend(ring(0) rows(3) position(11) region(lstyle(solid)) label(1 "Calibrated Model" ) label(2 "Data") ) ///
 ytitle({bf:Employment Share}, size("medlarge")) ///
  b1title({bf:Number of Employees}, size("medlarge")) ///
  ylabel(, angle(0)) ///
bar(1, fcolor("0 80 178")) bar(2, fcolor("209 80 0"))


graph export "$maindir/Outputs/Figure5a.pdf",replace

********************************** Figure 5b **********************************


import delimited "$maindir/RawData/Exit10.csv",clear

preserve

import delimited "$maindir/ProcessedData/Figure_5b.csv",clear

rename firmage_years_ year
rename exitrate_aspercentage_ exit_model


tempfile data
saveold `data',replace

restore

merge 1:1 year using `data'
drop if _merge==2
drop _merge



twoway (line  exit_model year, lwidth(thick) color("0 80 178")) ///
(connected  exit_data year,  color("209 80 0")), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Age}, size(large))  ///
  ytitle({bf: Lifcycle Exit Rate(%)},size(large)) ///
ylabel(0 (2) 17, gmax gmin labsize(medlarge)) ///
 xlabel(,labsize(medlarge)) /// 
legend( symys(*.5) symxs(*.5) size(4 )  ring(0) cols(1) position(1) region(lstyle(solid)) label(1 "Calibrated Model")  label(2 "Data"))


graph export "$maindir/Outputs/Figure5b.pdf",replace

********************************** Figure 6 Preliminaries **********************************



** Get average size from the data

clear
import delimited "$maindir/RawData/Average_firm_size_bds.csv", clear
keep year avg_size
ren avg_size avgsize_data
sort year 
save "$maindir/ProcessedData/size_tmp.dta",replace


** Get entry rate from data
clear
import delimited "$maindir/RawData/bds2018_fage.csv"
keep if fage=="a) 0"
keep year firms
rename firms newfirms
destring newfirms, replace

save "$maindir/ProcessedData/entry_tmp.dta",replace

** Get exit rate from data
clear
import delimited "$maindir/RawData/bds2018.csv"
keep year firms firmdeath_firms
gen exitrate_data=firmdeath_firms/firms
keep year exit

save "$maindir/ProcessedData/exit_tmp.dta",replace


clear
import delimited "$maindir/RawData/bds2018.csv"
keep year firms
destring firms, replace
sort year

save "$maindir/ProcessedData/entry_tmp_2.dta",replace

clear
use "$maindir/ProcessedData/entry_tmp.dta"
merge 1:1 year using "$maindir/ProcessedData/entry_tmp_2.dta"
drop _merge

gen entryrate_data = newfirms/firms
keep year entryrate_data
sort year
save "$maindir/ProcessedData/entry_tmp.dta",replace


** Get number of products from data

clear
import delimited "$maindir/RawData/ProductManu.csv"

ren v1 nprod
sort nprod

gen xx  = nprod
replace xx = 10 if nprod == 10

foreach y of varlist v* {
gen mass`y' = `y' - `y'[_n-1]
replace mass`y' = `y' if missing(mass`y')
replace mass`y' =  mass`y'/100
gen tmp`y' = mass`y'*xx
drop mass`y' `y'
} 

collapse (sum) tmp*
ren tmpv2  nprod1987
ren tmpv3  nprod1992
ren tmpv4  nprod1997
ren tmpv5  nprod2002
ren tmpv6  nprod2007
ren tmpv7  nprod2012

foreach vv of varlist npr* {
replace `vv' = `vv' / nprod1987
}

gen index = 1
reshape long nprod, i(index) j(year)
drop index

ren nprod nprod_data
save "$maindir/ProcessedData/nprod_tmp.dta",replace


********************************** Figure 6a **********************************

import delimited "$maindir/ProcessedData/Figure_6a.csv",clear

rename populationgrowthrate_aspercentag eta

generate remainder = mod(year,1)
keep if remainder==0
keep if year>=1970


tsset year
tsfilter hp smoothed=eta, trend(eta_trend) smooth (10)

generate upper = 3

generate lower = -1

drop if year>2070

twoway ( area upper year if inrange(year, 2020, 2070), color("230 230 230")) ///
(line eta year, lwidth(thick)  color("0  80 178")) ///
(line eta_trend year, lwidth(thick) color("cranberry")), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Year},size(large))  ytitle({bf: Labor Force Growth (%)},size(large)) ///
xline(1980,lcolor("cranberry") lwidth(medthick) lpattern(dash)) ///
 ylabel(,labsize(medlarge)) xlabel(,labsize(medlarge)) /// 
ysc(r(0(1)3)) ///
legend( order (2 3) symys(*.5) symxs(*.5) size(3)  ring(0) rows(3) position(1) region(lstyle(solid)) label(2 "Annual LF Growth") label(3 "HP Filtered Trend")) ylabel(0(1)3, gmax gmin)

graph export "$maindir/Outputs/Figure6a.pdf",replace


********************************** Figure 6b **********************************

import delimited "$maindir/ProcessedData/Figure_6b.csv",clear

generate remainder = mod(year,1)
keep if remainder==0
keep if year>=1970
drop if year>2070

merge 1:1 year using "$maindir/ProcessedData/entry_tmp.dta"
drop _merge

rename entryrate_aspercentage_ entryrate
rename counterfactualentry entryrate_LR 

replace entryrate_data=entryrate_data*100

** Entry rate
twoway (line entryrate year, lwidth(thick) color("0  80 178")) ///
(line entryrate_data year, lwidth(thick) color(emerald) ) ///
(line entryrate_LR year, lwidth(medthick) color(gs8) lpattern(dash)), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Year},size(large))  ytitle({bf: Entry Rate (%)},size(large)) ///
xline(1980,lcolor("cranberry") lwidth(medthick)) ylabel(5(2)14) ///
 ylabel(,labsize(medlarge)) xlabel(,labsize(medlarge)) ///
legend( symys(*.5) symxs(*.5) size(4)  ring(0) rows(3) position(1) region(lstyle(solid)) label(1 "Model") label(2 "Data") label(3 "BGP")) 

graph export "$maindir/Outputs/Figure6b.pdf",replace

********************************** Figure 6c **********************************

import delimited "$maindir/ProcessedData/Figure_6c.csv",clear

generate remainder = mod(year,1)
keep if remainder==0
keep if year>=1970
drop if year>2070

merge 1:1 year using "$maindir/ProcessedData/exit_tmp.dta"
drop _merge

rename exitrate_aspercentage_ exitrate
rename counterfactualexit exitrate_LR 

replace exitrate_data=exitrate_data*100

twoway (line exitrate year, lwidth(thick) color("0  80 178")) ///
(line exitrate_data year, lwidth(thick) color(emerald) ) ///
(line exitrate_LR year, lwidth(medthick) color(gs8) lpattern(dash)), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Year},size(large))  ytitle({bf: Exit Rate (%)},size(large)) ///
 ylabel(,labsize(medlarge)) xlabel(,labsize(medlarge)) ///
xline(1980,lcolor("cranberry") lwidth(medthick))  ylabel(5(2)14) ///
legend( symys(*.5) symxs(*.5) size(4)  ring(0) rows(3) position(1) label(1 "Model") label(2 "Data") label(3 "BGP")) 

graph export "$maindir/Outputs/Figure6c.pdf",replace

********************************** Figure 6d **********************************

import delimited "$maindir/ProcessedData/Figure_6d.csv",clear

generate remainder = mod(year,1)
keep if remainder==0
keep if year>=1970
drop if year>2070

merge 1:1 year using "$maindir/ProcessedData/size_tmp.dta"
drop _merge

rename averagefirmsize_asemployees_ avgsize
rename counterfactualsize avgsize_LR 

twoway (line avgsize year, lwidth(thick) color("0  80 178")) ///
(line avgsize_data year, lwidth(thick) color(emerald) ) ///
(line avgsize_LR year, lwidth(medthick) color(gs8) lpattern(dash)), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Year},size(large))  ytitle({bf: Average Firm Size},size(large)) ///
xline(1980,lcolor("cranberry") lwidth(medthick)) ///
 ylabel(,labsize(medlarge)) xlabel(,labsize(medlarge)) ///
legend( symys(*.5) symxs(*.5) size(4)  ring(0) rows(3) position(1) label(1 "Model") label(2 "Data") label(3 "BGP")) 

graph export "$maindir/Outputs/Figure6d.pdf",replace

********************************** Figure 7a **********************************

import delimited "$maindir/ProcessedData/Figure_7a.csv",clear


generate remainder = mod(year,1)
keep if remainder==0
keep if year>=1970
drop if year>2070

rename sharefirms10years oldshare
rename counterfactualshare10years oldshare_LR 

sort year
save "$maindir/ProcessedData/Figure_7a_fit.dta", replace

* Merge with data from BDS

clear
import delimited "$maindir/RawData/bds2021.csv"
keep if year >= 1990

destring firms, replace

* Total number of firms by year
egen totfirms = sum(firms), by(year)

* Keep all firms less or equal to 10 years old
drop if fagecoarse == "e) Left Censored"
drop if fagecoarse == "d) 11+"

* Sum all young firms
egen youngfirms = sum(firms), by(year)

* Compute share of old firms 
gen oldshare_bds = (1 - youngfirms/totfirms)*100

keep if fagecoarse == "a) 0"
keep year oldshare_bds
save "$maindir/ProcessedData/oldshare_bds.dta", replace


*Merge with model outcomes
use "$maindir/ProcessedData/Figure_7a_fit.dta"
merge 1:1 year using "$maindir/ProcessedData/oldshare_bds.dta"



twoway (line oldshare year, lwidth(thick) color("0  80 178")) ///
(line  oldshare_bds year,  lwidth(thick) color(emerald) ) ///
(line oldshare_LR year, lwidth(medthick) color(gs8) lpattern(dash)), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Year},size(large))  ytitle({bf: Share of Firms Above 10 yrs},size(large)) ///
xline(1980,lcolor("cranberry") lwidth(medthick)  lpattern(solid)) ///
 ylabel(,labsize(medlarge)) xlabel(,labsize(medlarge)) /// 
legend( symys(*.5) symxs(*.5) size(4)  ring(0) rows(3) position(1) label(1 "Model") /// 
label(2 "Data") label(3 "BGP")) ///
ylabel(30 40 50 60 70) yscale(r(25 70))

graph export "$maindir/Outputs/Figure7a.pdf",replace




********************************** Figure 7b **********************************

import delimited "$maindir/ProcessedData/Figure_7b.csv",clear

generate remainder = mod(year,1)
keep if remainder==0
keep if year>=1970
drop if year>2070

rename sharefirms2prods twoprods
rename sharefirms5prods fiveprods 

twoway (line twoprods year, lwidth(thick) color("0  80 178") yaxis(1)) ///
(line fiveprods year, lwidth(thick) color("cranberry")  yaxis(2) lpattern(solid)), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Year},size(large))  ytitle({bf: Share of Firms With 2+ Prods},size(large) axis(1)  color("0  80 178")) ///
ytitle({bf: Share of Firms With 5+ Prods},size(large) axis(2) color("cranberry")) /// 
 ylabel(,labsize(medlarge) axis(1)) xlabel(,labsize(medlarge)) ylabel(,labsize(medlarge) axis(2)) /// 
legend(off) 

graph export "$maindir/Outputs/Figure7b.pdf",replace


********************************** Figure 8a **********************************


import delimited "$maindir/ProcessedData/Figure_8a.csv",clear

generate remainder = mod(year,1)
keep if remainder==0
keep if year>=1970
drop if year>2070

rename costweightedmarkup avgmu
rename counterfactualmarkup avgmu_LR 


** Average Markups
twoway (line avgmu year, lwidth(thick) color("0  80 178")) ///
(line avgmu_LR year, lwidth(medthick) color(gs8) lpattern(dash)), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Year},size(large))  ytitle({bf: Average Markup},size(large)) ///
xline(1980,lcolor("cranberry") lwidth(medthick)) ///
 ylabel(,labsize(medlarge)) xlabel(,labsize(medlarge)) /// 
legend( symys(*.5) symxs(*.5) size(4)  ring(0) rows(3) position(4) label(1 "Average markup") label(2 "Average markup BGP")) 

graph export "$maindir/Outputs/Figure8a.pdf",replace

********************************** Figure 8b **********************************


import delimited "$maindir/ProcessedData/Figure_8b.csv",clear

rename firmage_years_ age
rename populationgrowth baseline_markup
rename v3 counterfact_markup 

drop if age>30

twoway (line baseline_markup age, lwidth(thick) color("0 80 178")) (line counterfact_markup age,  lwidth(thick) color("cranberry")), ///
graphregion(color(white) margin(l=0 r=0)) xlabel(#12) xtitle({bf: Age (Years)},size(large))  ytitle({bf:  Average Markup},size(medlarge)) ///
legend( symys(*.5) symxs(*.5) size(4 )  ring(0) rows(2) position(5) label(1 "2% Population Growth") label(2 "0.24% Population Growth")) ylabel(1(0.1)1.4) aspectratio(0.7)

graph export "$maindir/Outputs/Figure8b.pdf",replace



********************************** Figure 9 **********************************


import delimited "$maindir/ProcessedData/Figure_9.csv",clear

generate remainder = mod(year,1)
keep if remainder==0
keep if year>=1970
drop if year>2070



** Growth
twoway (line productivitygrowthrate year, lwidth(thick) color("0  80 178")) ///
 (line varietygrowthterm year, lwidth(thick) color("cranberry")) ///
  (line efficiencygrowthterm year, lwidth(thick) color("209  80 0")) , ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Year},size(large))  ytitle({bf: Contributions to Growth (%)},size(large)) ///
xline(1980,lcolor("cranberry") lwidth(medthick)) ///
 ylabel(,labsize(medlarge)) xlabel(,labsize(medlarge)) /// 
legend( symys(*.5) symxs(*.5) size(4)  ring(0) rows(3) position(3) label(1 "Total Growth") label(2 "Variety Growth") label(3 "Efficiency Growth")) 

graph export "$maindir/Outputs/Figure9.pdf",replace


********************************** Appendix Figure LifeCycle Changes **********************************

import delimited "$maindir/ProcessedData/Figure_App_2a.csv",clear

rename firmage_inyears_ age
drop if age>30


twoway (line  exit2populationgrowth age, lwidth(thick) color("0 80 178")) ///
(line  exit024populationgrowth age, lwidth(thick) color("cranberry")), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Age}, size(large))  ///
  ytitle({bf: Lifecycle Exit Rate},size(large)) ///
 xlabel(,labsize(medlarge)) /// 
legend( symys(*.5) symxs(*.5) size(4 )  ring(0) rows(1) position(1) region(lstyle(solid)) label(1 "2% LF Growth") label(2 "0.24% LF Growth") label(3 "Data")) 

graph export "$maindir/Outputs/Figure_App_2a.pdf",replace



import delimited "$maindir/ProcessedData/Figure_App_2b.csv",clear

rename firmage_inyears_ age
drop if age>30


twoway (line  logsales2populationgrowth age, lwidth(thick) color("0 80 178")) ///
(line  logsales024populationgrowth age, lwidth(thick) color("cranberry")), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Age}, size(large))  ///
  ytitle({bf: Lifecycle Sales Growth (Log Points)},size(large)) ///
 xlabel(,labsize(medlarge)) /// 
legend( symys(*.5) symxs(*.5) size(4 )  ring(0) rows(1) position(1) region(lstyle(solid)) label(1 "2% LF Growth") label(2 "0.24% LF Growth") label(3 "Data")) 

graph export "$maindir/Outputs/Figure_App_2b.pdf",replace

********************************** Appendix Figure Age Distribution Changes **********************************


import delimited "$maindir/ProcessedData/Figure_App_3.csv",clear

rename firmage_inyears_ age
drop if age>30




twoway (area  agedensity2populationgrowth age, lwidth(thick) color("0 80 178")) ///
(area  agedensity024populationgrowth age, lwidth(thick) color("cranberry")), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Age}, size(large))  ///
  ytitle({bf: Density of Age},size(large)) ///
 xlabel(,labsize(medlarge)) /// 
legend( symys(*.5) symxs(*.5) size(4 )  ring(0) rows(1) position(1) region(lstyle(solid)) label(1 "2% LF Growth") label(2 "0.24% LF Growth") label(3 "Data")) 

graph export "$maindir/Outputs/Figure_App_3.pdf",replace

********************************** Supplementary Material- Product Age **********************************

import delimited "$maindir/ProcessedData/Figure_SM_2a.csv",clear

rename firmage_inyears_ age
drop if age>30



twoway (line  oneproduct age, lwidth(medthick) color("215  40 0")) ///
(line  twoproduct age, lwidth(medthick) color("220  80 0")) ///
(line  threeproduct age, lwidth(medthick) color("230  140 0")) ///
(line fourproduct age, lwidth(medthick) color("250  200 0")) ///
(line  fiveproduct age, lwidth(medthick) color("255  230 0")) ///
(line  averageacrossfirms age, lwidth(thick) lpattern("dash") color("0 80 178")), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Age}, size(large))  ///
  ytitle({bf: Average Product Age},size(large)) ///
 xlabel(,labsize(medlarge)) /// 
legend( symys(*.5) symxs(*.5) size(4 )  ring(0) rows(3) position(11) region(lstyle(solid)) label(1 "One Product") label(2 "Two Products") label(3 "Three Products") label(4 "Four Products") label(5 "Five Products")) 

graph export "$maindir/Outputs/Figure_SM_2a.pdf",replace


import delimited "$maindir/ProcessedData/Figure_SM_2b.csv",clear

rename firmage_inyears_ age
drop if age>30



twoway (line  oneproduct age, lwidth(medthick) color("215  40 0")) ///
(line  twoproduct age, lwidth(medthick) color("220  80 0")) ///
(line  threeproduct age, lwidth(medthick) color("230  140 0")) ///
(line fourproduct age, lwidth(medthick) color("250  200 0")) ///
(line  fiveproduct age, lwidth(medthick) color("255  230 0")), ///
graphregion(color(white)) xlabel(#12) xtitle({bf: Age}, size(large))  ///
  ytitle({bf: Cond. Probability of No. of Products },size(large)) ///
 xlabel(,labsize(medlarge)) /// 
legend( symys(*.5) symxs(*.5) size(4 )  ring(0) rows(3) position(1) region(lstyle(solid)) label(1 "One Product") label(2 "Two Products") label(3 "Three Products") label(4 "Four Products") label(5 "Five Products")) 

graph export "$maindir/Outputs/Figure_SM_2b.pdf",replace





